home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-05-21 | 1.6 KB | 61 lines | [TEXT/ttxt] |
- ---<<<
-
- module webspaces6
- uses scriptx
- exports importsomemedia, createTheWindow, createTheBall, startSpaces6
- end
-
- in module webspaces6
-
- -- spaces6.sx
- -- demo of bouncing ball in a space, with sound when it hits the wall
- -- uses 3 controllers: gravity, movement, bounce
-
- function createTheWindow tc -> (
- local win := new window boundary:(new rect x1:0 y1:0 x2:300 y2:300) scale:40 title: tc
- win's x := 40
- win's y := 40
- show win
- -- make stroke brush for win
- win's stroke := new brush color:(new rgbcolor red:255 green:0 blue:0) pattern:blackPattern
-
- -- make fill brush for win
- win's fill := new brush color:(new rgbcolor red:100 green:100 blue:100) pattern:blackPattern
-
- local g := new gravity space:win wholespace: true
- local m := new movement space:win wholespace: true
- local b := new bounce space:win wholespace: true
- win
- )
-
- --importMedia a audioplayer
-
- function importsomemedia tc -> (
- local theStream := getStream theScriptDir "demosnd.aif" @Readable
- local da2 := importMedia theImportExportEngine theStream @sound @aiff @player container: tc
- da2.title := tc
- plug theStream
- da2
- )
-
- -- create a class that is both a 2dshape and a projectile
-
- class ball (TwoDShape, Projectile)
- end
-
- function createTheBall win da -> (
- local ballcolor := new brush color:(new rgbcolor red:0 green:200 blue:0) pattern:blackPattern
- local shp := new ball target:(new oval x1:0 y1:0 x2:20 y2:20) fill:ballcolor stroke:undefined
- shp's x := 50;
- shp's y := 50;
- shp's audioPlayer := da
- shp's elasticity := 1
- append win shp
- shp's velocity := (new point x:-8.0 y:4.0)
- )
-
-
- function startSpaces6 tc -> foreach tc load undefined
-
- --->>>
-